package com.idatax.auth.controller;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

@RestController
@RequestMapping("/.well-known")
public class OpenIdConfigurationController {

    @Value("${jwt.issuer}")
    private String issuer;

    @GetMapping("/openid-configuration")
    public Map<String, Object> getOpenIdConfiguration() {
        Map<String, Object> config = new HashMap<>();
        config.put("issuer", issuer);
        config.put("jwks_uri", issuer + "/api/auth/jwks");
        config.put("id_token_signing_alg_values_supported", new String[]{"RS256", "ES256"});
        config.put("subject_types_supported", new String[]{"public"});
        return config;
    }
}
